﻿
namespace System
{
	/// <summary>
	/// Providers extensions for the GUID type
	/// </summary>
	public static class GuidExtensions
	{
		/// <summary>
		/// Generates a long value from the guid
		/// </summary>
		/// <param name="guid">The identifiers</param>
		/// <returns>The long value from it</returns>
		public static long ToLong(this Guid guid)
		{
			byte[] _bytes = guid.ToByteArray();
			long value = ((long)_bytes[0]) | 
				((long)_bytes[1] << 8) | 
				((long)_bytes[2] << 16) | 
				((long)_bytes[3] << 24) |
				((long)_bytes[4] << 32);
			return value;
		}
		/// <summary>
		/// Generates an int value from the guid
		/// </summary>
		/// <param name="guid">The identifier</param>
		/// <returns>An integer value</returns>
		public static int ToInt(this Guid guid)
		{
			byte[] _bytes = guid.ToByteArray();
			int value = ((int)_bytes[0]) |
				((int)_bytes[1] << 8) |
				((int)_bytes[2] << 16) |
				((int)_bytes[3] << 24);
				
			return value;
		}
	}
}
